Conversation
| @@ -0,0 +1,9 @@ | |||
| namespace PriorityQueue; | |||
|
|
|||
| public class Program | |||
There was a problem hiding this comment.
Это не надо сразу по двум причинам:
- Можно было сделать очередь с приоритетами библиотекой (
<OutputType>Library</OutputType>в .csproj), и тогда точка входа была бы не нужна вовсе. - Если бы точка входа была нужна, её лучше было реализовать с помощью top-level statements, без всяких class Program и Main
| /// </summary> | ||
| public class Queue | ||
| { | ||
| private QueueElement? Head; |
| /// <param name="element">Adding element</param> | ||
| public void Enqueue(int element, int priority) | ||
| { | ||
|
|
There was a problem hiding this comment.
Лишняя пустая строчка, обычно после { пустые строки не ставятся
| public bool IsEmpty() | ||
| { | ||
| return Head == null; | ||
| } |
There was a problem hiding this comment.
Заказывали свойство Empty, получили метод IsEmpty(). В реальной жизни у кого-то не собрался бы проект, и кто-то получил бы неустойку за ошибку в протоколе.
| return; | ||
| } | ||
| var item = new QueueElement(element, priority); | ||
| if (Head.Priority < priority) |
There was a problem hiding this comment.
nullability-анализ недоволен, сразу минус балл :)
| Priority = priority; | ||
| } | ||
|
|
||
|
|
|
|
||
| public class Tests | ||
| { | ||
| Queue queue; |
There was a problem hiding this comment.
| Queue queue; | |
| private Queue queue; |
| private static IEnumerable<TestCaseData> QueueForTest | ||
| => new TestCaseData[] | ||
| { | ||
| new TestCaseData(new Queue()), | ||
| }; |
There was a problem hiding this comment.
Это не нужно, есть же поле queue и SetUp, который его инициализирует. Сейчас получается, что это поле вообще не используется.
| public void QueueShouldReturnValueWhenAddedSomething(Queue queue) | ||
| { | ||
| queue.Enqueue(12, 1); | ||
| Assert.True(queue.Dequeue() == 12); |
There was a problem hiding this comment.
Assert.AreEqual или Assert.That
| { | ||
| new TestCaseData(new Queue()), | ||
| }; | ||
| } No newline at end of file |
There was a problem hiding this comment.
Нигде не проверяется, что очередь и вправду очередь, а не просто структура данных, которая запоминает первое значение с максимальным приоритетом. Надо было несколько значений попробовать взять.
Первая контрольная, первая попытка